<template>
  <div ref="myChart" style="width: 1000px;height:700px;">

  </div>
</template>

<script>
export default {
  name: "SetmealStatistic",
  data(){
    return {
      headers:this.$cookies.get("token") != null ? this.$cookies.get("token") : '',
      option:{
        title: {
          text: '套餐预约占比',
          subtext: 'Fake Data',
          left: 'center'
        },
        tooltip: {
          trigger: 'item'
        },
        legend: {
          orient: 'vertical',
          left: 'left'
        },
        series: [
          {
            name: 'Access From',
            type: 'pie',
            radius: '50%',
            data: [
              { value: 1048, name: 'Search Engine' },
              { value: 735, name: 'Direct' },
              { value: 580, name: 'Email' },
              { value: 484, name: 'Union Ads' },
              { value: 300, name: 'Video Ads' }
            ],
            emphasis: {
              itemStyle: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: 'rgba(0, 0, 0, 0.5)'
              }
            }
          }
        ]
      }
    }
  },
  methods:{
    init(){
      if(this.$refs.myChart){
        let myCharts = this.$echarts.init(this.$refs.myChart)
        myCharts.setOption(this.option)
      }

    }
  },
  mounted() {
    this.$axios.get("/api/report/getSetmealReport.do",{
      headers:{
        'token':this.headers
      }
    }).then((res)=>{
      if(res.data.flag){
        this.option.series[0].data = res.data.data.setmealCount
        this.init();
      }
      console.log(this.option)

    })

  }
}
</script>

<style scoped>

</style>